from tortoise import BaseDBAsyncClient

RUN_IN_TRANSACTION = True


async def upgrade(db: BaseDBAsyncClient) -> str:
    return """
        CREATE TABLE IF NOT EXISTS `t_role` (
    `id` BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `created_by` VARCHAR(50) COMMENT '创建者' DEFAULT 'admin',
    `updated_by` VARCHAR(50) COMMENT '更新者' DEFAULT 'admin',
    `created_at` DATETIME(6) NOT NULL COMMENT '创建时间' DEFAULT CURRENT_TIMESTAMP(6),
    `updated_at` DATETIME(6) NOT NULL COMMENT '更新时间' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
    `deleted` BOOL NOT NULL COMMENT '逻辑删除标志' DEFAULT 0,
    `role_name` VARCHAR(50) NOT NULL UNIQUE COMMENT '用户名',
    `is_active` BOOL NOT NULL COMMENT '是否激活' DEFAULT 1
) CHARACTER SET utf8mb4;
CREATE TABLE IF NOT EXISTS `t_user` (
    `id` BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `created_by` VARCHAR(50) COMMENT '创建者' DEFAULT 'admin',
    `updated_by` VARCHAR(50) COMMENT '更新者' DEFAULT 'admin',
    `created_at` DATETIME(6) NOT NULL COMMENT '创建时间' DEFAULT CURRENT_TIMESTAMP(6),
    `updated_at` DATETIME(6) NOT NULL COMMENT '更新时间' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
    `deleted` BOOL NOT NULL COMMENT '逻辑删除标志' DEFAULT 0,
    `username` VARCHAR(50) NOT NULL UNIQUE COMMENT '用户名',
    `email` VARCHAR(100) NOT NULL UNIQUE COMMENT '电子邮件',
    `password` VARCHAR(255) NOT NULL COMMENT '密码',
    `is_active` BOOL NOT NULL COMMENT '是否激活' DEFAULT 1,
    `is_superuser` BOOL NOT NULL COMMENT '是否为超级用户' DEFAULT 0
) CHARACTER SET utf8mb4;
CREATE TABLE IF NOT EXISTS `aerich` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `version` VARCHAR(255) NOT NULL,
    `app` VARCHAR(100) NOT NULL,
    `content` JSON NOT NULL
) CHARACTER SET utf8mb4;"""


async def downgrade(db: BaseDBAsyncClient) -> str:
    return """
        """


MODELS_STATE = (
    "eJztmG1v2zYQgP+KoU8ZkBWyZL143+wsWz009pA629CmECiJsoVIlCpRTY0i/313tGW92p"
    "OzZvZafzGs453Ie47i3fGLFEYuDdJXt1FApZ96XyRGQvxTkV/2JBLHhRQFnNjCQuJWkuvY"
    "KU+Iw0HqkSClIHJp6iR+zP2IgZRlQYDCyAFFny0KUcb8jxm1eLSgfEkTGHj/AcQ+c+lnmu"
    "aP8YPl+TRwKwv1XZxbyC2+ioVs7C8mjP8idHFC23KiIAtZoR+v+DJiWwOfcZQuKKMJ4RRn"
    "4EmGHuACN67mTq0XW6isV1mycalHsoCXPO6IwYkYIoTVpMLHBc7y41BRVNVQZFU3tYFhaK"
    "Zsgq5YUnPIeFo7XABZv0pgmfw6mc7R0QjitA4fCp6EDeFkbSV4F4CdhCISy141QV8tSdKO"
    "uWpVww1O1nHncEu8NzS3uHOVgnexzXLgEnFDn0kN5tJ9pil9G35B9T4zZVmTusUgJJ+tgL"
    "IFX8KjJu/B+8fo9ur16PZCk3+oMp5uRhQxhLQLulnsPoNu1eoU6Oq6N4BfzZZPiW6+Cwlv"
    "0v0ZRrgf0v37d21ZI+xuTF/lfzrwbpweXYC3nh+1vaxrnn6fDTVv0JE5eObOWLDabII9zO"
    "eTm+u389HN7/jmME0/BgLcaH6NI4qQrmrSC70Wn+1Len9O5q97+Nh7N5teC65RyheJmLHQ"
    "m7+TcE0k45HFokeLuKWzNZfmuFo/psPDXbU8tXCXP67vNtybxRfRhlKEIv9m+o+gIiGsPd"
    "Ilq1qYbTB7qci2F0QQ2qGswpdsesM+ftUKBHio6xhsSOUg8VyjW5j3pf3Z7E0louNJrQiY"
    "3t2Mr28v+iKUoOTzSm1QIMdSzxIPBySritGzctXXqryAt6EpJtBVVKQ7kN3TyFN+akHh7H"
    "9q4bp3M1fs/sPtvMXdOKgUD7kqcETpnoPHlavax97B2Dt4D6XiFgU2cR4eSeJajZFIiXbp"
    "NodCJaxLCCMLwQ39RK82vdRdKjqbRo8l5Jf7e6ws1zn3WOce69xjnXus06F77rG+4aL73G"
    "N9V+E+91jH77Gw1Du0xSrbnDustixFQ+IHhyDdGhyfp6oBSVvDfSsTep8NqKc/h2pf7oIV"
    "tHZyFWNVsDFJ08coaTkidrMt23wdvP8q0dsOnPaGKfefA1XRtA5QQWsnVDF2vg84zmkLxN"
    "IspkneYB8Gu2J6CqmuDHxAVWzDXBOOD4MSo3w0HzsEJ3IlM6KJ7yyllkuZzcjlvmsZUuic"
    "zLXMN3Qno/QHxsBU9cH2KmYr2XcD88+3LZ9okuKSDshYJZMjJ6zuFF8+TeGncQDEjfr/E+"
    "CLFE8wI6espZP+7e1suuPSpDCpgbxj4OB713f4ZS/wU/7hNLHuoYheV5JKDu/iZvRXnevV"
    "m9m43vDiC8bHTi9PfwNEvs52"
)
